package de.unistuttgart.iaaskpimonitoring.esper.processingmanagement;

import java.util.Map;
import de.unistuttgart.iaaskpimonitoring.esper.configurationmanagement.*;

public class NodeFactoryManager {
	
	private static Map<String, NodeFactory> existingNodeFactoryInstances;
	
	public static NodeFactory getInstance(String opEltName) throws ClassNotFoundException, IllegalAccessException, InstantiationException{
		NodeFactory factoryToReturn;
		if(existingNodeFactoryInstances.containsKey(opEltName)){
			factoryToReturn = existingNodeFactoryInstances.get(opEltName);
		}else{
			factoryToReturn = (NodeFactory) Class.forName(Configuration.getOperatorMappings().get(existingNodeFactoryInstances.get(opEltName))).newInstance();
			existingNodeFactoryInstances.put(opEltName, factoryToReturn);
		}

		return factoryToReturn;
	
	}

	

}
